package ca.uwindsor.cs.deepweb.utility.documentanalysis;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class TermsExtractorbyWeightRange {

	protected double startingweight;

	protected double endingweight;

	/**
	 * @param startweight
	 *            included
	 * @param endweight
	 *            excluded
	 * 
	 */
	public TermsExtractorbyWeightRange(double startweight, double endweight) {
		this.startingweight = startweight;
		this.endingweight = endweight;
	}

	public void load(String file) {
		InputStreamReader reader = null;
		BufferedReader bufferedreader_in;
		String string_line = new String();
		String[] temp;
		try {
			reader = new InputStreamReader(new FileInputStream(file));
			bufferedreader_in = new BufferedReader(reader);
			string_line = bufferedreader_in.readLine();
			double w;
			while (string_line != null) {
				if (!string_line.equals("")) {
					temp = string_line.split("\t");
					w = Double.parseDouble(temp[1]);
					if (w >= startingweight && w < endingweight) {
						System.out.println(temp[0]);
					}
					// list.add(cell);
				}
				string_line = bufferedreader_in.readLine();
			}
		} catch (IOException ex) {
			ex.printStackTrace();
		}
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
//		args = new String[3];
//		args[0] = "D:/学习资料/Graduate Study/Winter2008/60-590/Broder et al 2006/correct/gov2_0_5digit_with_queryweight.txt";
//		args[1] = "0";
//		args[2] = "90.44";
		if (args.length != 3) {
			System.exit(-1);
		}
		TermsExtractorbyWeightRange e = new TermsExtractorbyWeightRange(Double
				.parseDouble(args[1]), Double.parseDouble(args[2]));
		e.load(args[0]);
	}

}
